/**
 * Copyright 2014-2021 the original author or authors.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.webank.webase.node.mgr.deploy.entity;

import java.util.Date;

import com.webank.webase.node.mgr.base.enums.ChainStatusEnum;
import com.webank.webase.node.mgr.base.enums.RunTypeEnum;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@EqualsAndHashCode
@ToString
@NoArgsConstructor
public class TbChain {

    public static TbChain init(String chainName,
                                String chainDesc,
                                String version,
                                byte encryptType,
                                ChainStatusEnum status,
                               RunTypeEnum runTypeEnum,
                               String webaseSignAddr

    ){
        Date now = new Date();
        TbChain chain  = new TbChain();
        chain.setChainName(chainName);
        chain.setChainDesc(chainDesc);
        chain.setVersion(version);
        chain.setEncryptType(encryptType);
        chain.setChainStatus(status.getId());
        chain.setCreateTime(now);
        chain.setModifyTime(now);
        chain.setRunType(runTypeEnum.getId());
        chain.setWebaseSignAddr(webaseSignAddr);
        return chain;
    }

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.id
     *
     * @mbg.generated
     */
    private Integer id;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.chain_name
     *
     * @mbg.generated
     */
    private String chainName;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.desc
     *
     * @mbg.generated
     */
    private String chainDesc;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.version
     *
     * @mbg.generated
     */
    private String version;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.encrypt_type
     *
     * @mbg.generated
     */
    private Byte encryptType;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.status
     *
     * @mbg.generated
     */
    private Byte chainStatus;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.webase_sign_addr
     *
     * @mbg.generated
     */
    private String webaseSignAddr;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.run_type
     *
     * @mbg.generated
     */
    private Byte runType;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.create_time
     *
     * @mbg.generated
     */
    private Date createTime;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_chain.modify_time
     *
     * @mbg.generated
     */
    private Date modifyTime;
}